﻿using ETA.DomainEnum;
using ETA.Entity;
using FluentNHibernate.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ETA.EntityMappings
{
    public class FlowLogMap : ClassMap<FlowLog>
    {
        public FlowLogMap()
        {
            Id(x => x.FlowLogId);
            // Map(x => x.RegistrationMainFormId); //TODO 此处不再必要 严重注意 因为下方 已经管理实体 RegistrationMainForm 无须重复关联id
            Map(x => x.FlowLogStateEnum).CustomType<FlowLogStateEnum>().Column("State");
            Map(x => x.HandlerStateEnum).CustomType<HandlerStateEnum>().Column("HandlerState");
            Map(x => x.SourceEnum).CustomType<SourceEnum>().Column("Source"); 
            References(x => x.FlowStepInfo).Column("FlowStepId");
            HasMany<WebMessage>(x => x.WebMessages).KeyColumn("FlowLogId").Where(t => t.IsDelete == false).LazyLoad();
            References(x => x.RegistrationMainForm).Column("RegistrationMainFormId");
            Map(x => x.IsDelete);
            Map(x => x.ModifyDate);
            Map(x => x.CreateDate);
            Map(x => x.IsNew);
            Map(x => x.HandlerDate);
        }
    }
}
